/**
 * 
 */
package com.pdt.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.pdt.service.RobotServiceDAO;
import com.pdt.util.ResponseUtil;

/**
 * @author 作者：Zhangyangyang
 * @version 创建时间：2017年6月16日 下午1:34:05 类说明
 */
@Controller
public class RobotController {
	
	@Autowired
	private RobotServiceDAO robotServiceDAO;
	
	//用户登录
	@RequestMapping(value = "/pdt/login", method = RequestMethod.POST)
	@ResponseBody
	public void login(@RequestBody JSONObject data, HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		ResponseUtil.write(response, robotServiceDAO.login(data));
	}
	
	// 机器人入库
	@RequestMapping(value = "/pdt/inHouse", method = RequestMethod.POST)
	@ResponseBody
	public void inHouse(@RequestBody JSONObject data, HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		ResponseUtil.write(response, robotServiceDAO.inHouse(data));
	}
	
	//机器人出库
	@RequestMapping(value = "/pdt/outHouse", method = RequestMethod.POST)
	@ResponseBody
	public void outHouse(@RequestBody JSONObject data, HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		ResponseUtil.write(response, robotServiceDAO.outHouse(data));
	}
	
	//查询sn
	@RequestMapping(value = "/pdt/searchSN", method = RequestMethod.POST)
	@ResponseBody
	public void searchSN(@RequestBody JSONObject data, HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		ResponseUtil.write(response, robotServiceDAO.searchSN(data));
	}
	
	//添加商户
	@RequestMapping(value = "/pdt/addMerchants", method = RequestMethod.POST)
	@ResponseBody
	public void addMerchants(@RequestBody JSONObject data, HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		ResponseUtil.write(response, robotServiceDAO.addMerchants(data));
	}
	
	
}
